package br.com.alinesoftware.app.entity;

import java.io.Serializable;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.MappedSuperclass;
import javax.persistence.OneToMany;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

import org.hibernate.annotations.ForeignKey;

@MappedSuperclass
public abstract class Mesa implements Serializable {

	private static final long serialVersionUID = 641952520166388633L;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO, generator = "SE_MESA")
	@Column(nullable = false, length = 5)
	private Long id;

	@NotNull
	@Size(max = 255)
	@Column
	private String observacao;

	@NotNull
	@Column(length = 5)
	private Double latitude;

	@NotNull
	@Column(length = 5)
	private Double longitude;

	@ManyToOne(targetEntity = EtiquetaQRCodeEntity.class, fetch = FetchType.LAZY)
	@ForeignKey(name = "FK_MESA_ETIQUETAQRCODE")
	@NotNull
	@JoinColumn
	private EtiquetaQRCode etiquetaQRCode;

	@OneToMany(targetEntity = EstabelecimentoMesaEntity.class, fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "estabelecimento")
	@ForeignKey(name = "FK_ESTABELMESA_MESA")
	private List<EstabelecimentoMesa> estabelecimentos;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getObservacao() {
		return observacao;
	}

	public void setObservacao(String observacao) {
		this.observacao = observacao;
	}

	public Double getLatitude() {
		return latitude;
	}

	public void setLatitude(Double latitude) {
		this.latitude = latitude;
	}

	public Double getLongitude() {
		return longitude;
	}

	public void setLongitude(Double longitude) {
		this.longitude = longitude;
	}

	public EtiquetaQRCode getEtiquetaQRCode() {
		return etiquetaQRCode;
	}

	public void setEtiquetaQRCode(EtiquetaQRCode etiquetaQRCode) {
		this.etiquetaQRCode = etiquetaQRCode;
	}

	public List<EstabelecimentoMesa> getEstabelecimentos() {
		return estabelecimentos;
	}

	public void setEstabelecimentos(List<EstabelecimentoMesa> estabelecimentos) {
		this.estabelecimentos = estabelecimentos;
	}

}
